#include "Screen.h"

Screen::Screen()
:   viewWorld(FloatRect(0.f,0.f,(float)MAIN_WIDTH,(float)MAIN_HEIGHT)),
    viewGameMenu(FloatRect(0.f,0.f,(float)MAIN_WIDTH,(float)MAIN_HEIGHT)),
    viewMainMenu(FloatRect(0.f,0.f,(float)MAIN_WIDTH,(float)MAIN_HEIGHT)),
    viewFight(FloatRect(0.f,0.f,(float)MAIN_WIDTH,(float)MAIN_HEIGHT)),
    window(VideoMode(MAIN_WIDTH, MAIN_HEIGHT), "Menu Principal")

{
    window.SetFramerateLimit(40);
    window.Clear(COLOR_BLACK);
}

Screen::~Screen()
{

}

void Screen::drawWorld()
{
    updateViewWorld();
    window.Clear(COLOR_BLACK);
    vector<Sprite*>::iterator it;
    for(it=worldSprite.begin(); it!=worldSprite.end(); it++)
    {
        window.Draw(**it);
    }
    window.SetView(viewWorld);

}


void Screen::setViewWorldPosition( const float* x, const float* y )
{
    worldX = x;
    worldY = y;
    viewWorld.SetCenter(*worldX, *worldY);
}

void Screen::updateViewWorld()
{
    viewWorld.SetCenter((float)*worldX, (float)*worldY);
}

void Screen::drawMainMenu()
{
    window.Clear(COLOR_BLACK);
    vector<Sprite*>::iterator it;
    for(it=mainMenuSprite.begin(); it!=mainMenuSprite.end(); it++)
    {
        window.Draw(**it);
    }

    window.SetView(viewMainMenu);
}

void Screen::display()
{
    window.Display();
}

void Screen::drawFight()
{
    window.Clear(COLOR_BLACK);
    vector<Sprite*>::iterator it;
    for(it=fightSprite.begin(); it!=fightSprite.end(); it++)
    {
        window.Draw(**it);
    }

    window.SetView(viewFight);
}

void Screen::drawGameMenu(int i)
{
    window.Clear(COLOR_BLACK);
    vector<Sprite*>::iterator it;
    for(it=gameMenuSprite.begin(); it!=gameMenuSprite.end(); it++)
    {
        window.Draw(**it);
    }
    window.Draw(*gameMenuSprite[i]);

    window.SetView(viewGameMenu);
}


void Screen::drawNewGameMenu(){

    window.Clear(COLOR_BLACK);
    vector<Sprite*>::iterator it;
    for(it=newGameSprite.begin(); it!=newGameSprite.end(); it++)
    {
        window.Draw(**it);
    }

    window.SetView(viewNewGame);


}
